package com.yuelan.apartment.controller;

import com.yuelan.apartment.service.RentService;
import com.yuelan.common.core.web.controller.BaseController;
import com.yuelan.common.core.web.domain.AjaxResult;
import com.yuelan.common.core.web.page.TableDataInfo;
import com.yuelan.common.log.annotation.Log;
import com.yuelan.common.log.enums.BusinessType;
import com.yuelan.common.security.annotation.Logical;
import com.yuelan.common.security.annotation.RequiresPermissions;
import com.yuelan.common.security.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @description:
 * @Author: ZhaoYi
 * @date: 24-6-28 2:39
 */
@RestController
@RequestMapping("/rent")
public class RentController extends BaseController {

    @Autowired
    private RentService rentService;


    @GetMapping("/profit")
    @RequiresRoles(value = {"admin", "common"}, logical = Logical.OR)
    @Log(title = "租金收益统计", businessType = BusinessType.QUERY)
    public AjaxResult rentProfit(String year) {
        return success(rentService.yearProfit(year));
    }


    @GetMapping("/billStatus")
    @RequiresRoles(value = {"admin", "common"}, logical = Logical.OR)
    @Log(title = "当月账单状态", businessType = BusinessType.QUERY)
    public TableDataInfo viewRentBillType(String status, int pageNum, int pageSize) {
        return rentService.billStatus(status, pageNum, pageSize);
    }


    @GetMapping("/updateBill")
    @RequiresPermissions("apartment:rent:updateBill")
    @Log(title = "处理账单逾期", businessType = BusinessType.UPDATE)
    public AjaxResult rentBillOverdue() {
        rentService.updateBillOverdueCountDownLatch();
        return success();
    }


}
